libostree: new function ostree_repo_checkout_at
authorGiuseppe Scrivano <gscrivan@redhat.com>
Wed, 27 Jul 2016 08:38:36 +0000 (10:38 +0200)
committerAtomic Bot <atomic-devel@projectatomic.io>
Sat, 30 Jul 2016 11:24:52 +0000 (11:24 +0000)
Provide a gobject introspection safe version for
`ostree_repo_checkout_tree_at'.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #417
Approved by: cgwalters

apidoc/ostree-sections.txt
src/libostree/libostree.sym
src/libostree/ostree-repo-checkout.c
src/libostree/ostree-repo.h

index 8b6337f701b46c194eea71fa170e05034d7d6bd9..37c7e11e859d501238293e63416e563aee536a0d 100644 (file)
@@ -344,6 +344,7 @@ OstreeRepoCheckoutMode
 OstreeRepoCheckoutOverwriteMode
 ostree_repo_checkout_tree
 ostree_repo_checkout_tree_at
+ostree_repo_checkout_at
 ostree_repo_checkout_gc
 ostree_repo_read_commit
 OstreeRepoListObjectsFlags
index 04e364535d78e4ce7378915977f313b8c0be27dd..3d05ac0e80dded65d7d411c7631faa51089f460c 100644 (file)
@@ -355,4 +355,5 @@ LIBOSTREE_2016.8 {
 global:
         ostree_checksum_b64_to_bytes;
         ostree_checksum_b64_from_bytes;
+        ostree_repo_checkout_at;
 } LIBOSTREE_2016.7;
index 265270b196b75615b9280a7b049ba5682c1ed542..1010d2396c250f5dcf1524a8cb573fce4e95ab39 100644 (file)
@@ -104,14 +104,14 @@ checkout_object_for_uncompressed_cache (OstreeRepo      *self,
 
 static gboolean
 fsync_is_enabled (OstreeRepo   *self,
-                  OstreeRepoCheckoutOptions *options)
+                  OstreeRepoCheckoutAtOptions *options)
 {
   return !(self->disable_fsync || options->disable_fsync);
 }
 
 static gboolean
 write_regular_file_content (OstreeRepo            *self,
-                            OstreeRepoCheckoutOptions *options,
+                            OstreeRepoCheckoutAtOptions *options,
                             GOutputStream         *output,
                             GFileInfo             *file_info,
                             GVariant              *xattrs,
@@ -181,7 +181,7 @@ write_regular_file_content (OstreeRepo            *self,
 
 static gboolean
 checkout_file_from_input_at (OstreeRepo     *self,
-                             OstreeRepoCheckoutOptions *options,
+                             OstreeRepoCheckoutAtOptions *options,
                              GFileInfo      *file_info,
                              GVariant       *xattrs,
                              GInputStream   *input,
@@ -264,7 +264,7 @@ checkout_file_from_input_at (OstreeRepo     *self,
  */
 static gboolean
 checkout_file_unioning_from_input_at (OstreeRepo     *repo,
-                                      OstreeRepoCheckoutOptions  *options,
+                                      OstreeRepoCheckoutAtOptions  *options,
                                       GFileInfo      *file_info,
                                       GVariant       *xattrs,
                                       GInputStream   *input,
@@ -334,7 +334,7 @@ checkout_file_unioning_from_input_at (OstreeRepo     *repo,
 
 static gboolean
 checkout_file_hardlink (OstreeRepo                          *self,
-                        OstreeRepoCheckoutOptions           *options,
+                        OstreeRepoCheckoutAtOptions           *options,
                         const char                          *loose_path,
                         int                                  destination_dfd,
                         const char                          *destination_name,
@@ -391,7 +391,7 @@ checkout_file_hardlink (OstreeRepo                          *self,
 
 static gboolean
 checkout_one_file_at (OstreeRepo                        *repo,
-                      OstreeRepoCheckoutOptions         *options,
+                      OstreeRepoCheckoutAtOptions         *options,
                       GFile                             *source,
                       GFileInfo                         *source_info,
                       int                                destination_dfd,
@@ -627,7 +627,7 @@ checkout_one_file_at (OstreeRepo                        *repo,
  */
 static gboolean
 checkout_tree_at (OstreeRepo                        *self,
-                  OstreeRepoCheckoutOptions         *options,
+                  OstreeRepoCheckoutAtOptions       *options,
                   int                                destination_parent_fd,
                   const char                        *destination_name,
                   OstreeRepoFile                    *source,
@@ -813,7 +813,7 @@ ostree_repo_checkout_tree (OstreeRepo               *self,
                            GCancellable             *cancellable,
                            GError                  **error)
 {
-  OstreeRepoCheckoutOptions options = { 0, };
+  OstreeRepoCheckoutAtOptions options = { 0, };
 
   options.mode = mode;
   options.overwrite_mode = overwrite_mode;
@@ -827,7 +827,7 @@ ostree_repo_checkout_tree (OstreeRepo               *self,
 }
 
 /**
- * ostree_repo_checkout_tree_at:
+ * ostree_repo_checkout_tree_at: (skip)
  * @self: Repo
  * @options: (allow-none): Options
  * @destination_dfd: Directory FD for destination
@@ -837,7 +837,7 @@ ostree_repo_checkout_tree (OstreeRepo               *self,
  * @error: Error
  *
  * Similar to ostree_repo_checkout_tree(), but uses directory-relative
- * paths for the destination, uses a new `OstreeRepoCheckoutOptions`,
+ * paths for the destination, uses a new `OstreeRepoCheckoutAtOptions`,
  * and takes a commit checksum and optional subpath pair, rather than
  * requiring use of `GFile` APIs for the caller.
  *
@@ -846,19 +846,63 @@ ostree_repo_checkout_tree (OstreeRepo               *self,
  * cache.
  */
 gboolean
-ostree_repo_checkout_tree_at (OstreeRepo                         *self,
+ostree_repo_checkout_tree_at (OstreeRepo                        *self,
                               OstreeRepoCheckoutOptions         *options,
                               int                                destination_dfd,
                               const char                        *destination_path,
                               const char                        *commit,
                               GCancellable                      *cancellable,
                               GError                           **error)
+{
+  OstreeRepoCheckoutAtOptions new_opts = {0, };
+  new_opts.mode = options->mode;
+  new_opts.overwrite_mode = options->overwrite_mode;
+  new_opts.enable_uncompressed_cache = options->enable_uncompressed_cache;
+  new_opts.disable_fsync = options->disable_fsync;
+  new_opts.process_whiteouts = options->process_whiteouts;
+  new_opts.no_copy_fallback = options->no_copy_fallback;
+  new_opts.subpath = options->subpath;
+  new_opts.devino_to_csum_cache = options->devino_to_csum_cache;
+  return ostree_repo_checkout_at (self, &new_opts, destination_dfd,
+                                  destination_path, commit, cancellable, error);
+}
+
+/**
+ * ostree_repo_checkout_at:
+ * @self: Repo
+ * @options: (allow-none): Options
+ * @destination_dfd: Directory FD for destination
+ * @destination_path: Directory for destination
+ * @commit: Checksum for commit
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Similar to ostree_repo_checkout_tree(), but uses directory-relative
+ * paths for the destination, uses a new `OstreeRepoCheckoutAtOptions`,
+ * and takes a commit checksum and optional subpath pair, rather than
+ * requiring use of `GFile` APIs for the caller.
+ *
+ * It also replaces ostree_repo_checkout_at() which was not safe to
+ * use with GObject introspection.
+ *
+ * Note in addition that unlike ostree_repo_checkout_tree(), the
+ * default is not to use the repository-internal uncompressed objects
+ * cache.
+ */
+gboolean
+ostree_repo_checkout_at (OstreeRepo                        *self,
+                         OstreeRepoCheckoutAtOptions       *options,
+                         int                                destination_dfd,
+                         const char                        *destination_path,
+                         const char                        *commit,
+                         GCancellable                      *cancellable,
+                         GError                           **error)
 {
   gboolean ret = FALSE;
   g_autoptr(GFile) commit_root = NULL;
   g_autoptr(GFile) target_dir = NULL;
   g_autoptr(GFileInfo) target_info = NULL;
-  OstreeRepoCheckoutOptions default_options = { 0, };
+  OstreeRepoCheckoutAtOptions default_options = { 0, };
 
   if (!options)
     {
@@ -920,7 +964,7 @@ devino_equal (gconstpointer   a,
  * ostree_repo_write_directory_to_mtree() using a (normally modified)
  * directory.  In order for OSTree to optimally detect just the new
  * files, use this function and fill in the `devino_to_csum_cache`
- * member of `OstreeRepoCheckoutOptions`, then call
+ * member of `OstreeRepoCheckoutAtOptions`, then call
  * ostree_repo_commit_set_devino_cache().
  *
  * Returns: (transfer full): Newly allocated cache
index 872f9b813cb0ca750600dc44f616488c07b3a259..28766a24596843e129e37a1beff23fd2790dbb4b 100644 (file)
@@ -624,13 +624,14 @@ typedef struct {
 } OstreeRepoImportArchiveOptions;
 
 _OSTREE_PUBLIC
-gboolean      ostree_repo_import_archive_to_mtree (OstreeRepo                   *self,
+gboolean      ostree_repo_import_archive_to_mtree (OstreeRepo                      *self,
                                                    OstreeRepoImportArchiveOptions  *opts,
-                                                   void                         *archive, /* Really struct archive * */
-                                                   OstreeMutableTree            *mtree,
-                                                   OstreeRepoCommitModifier     *modifier,
-                                                   GCancellable                 *cancellable,
-                                                   GError                      **error);
+                                                   void                            *archive, /* Really struct archive * */
+                                                   OstreeMutableTree               *mtree,
+                                                   OstreeRepoCommitModifier        *modifier,
+                                                    GCancellable                   *cancellable,
+                                                    GError                        **error);
+
 /**
  * OstreeRepoExportArchiveOptions:
  *
@@ -735,7 +736,7 @@ ostree_repo_checkout_tree (OstreeRepo               *self,
                            GError                  **error);
 
 /**
- * OstreeRepoCheckoutOptions:
+ * OstreeRepoCheckoutOptions: (skip)
  *
  * An extensible options structure controlling checkout.  Ensure that
  * you have entirely zeroed the structure, then set just the desired
@@ -761,6 +762,32 @@ typedef struct {
   gpointer unused_ptrs[7];
 } OstreeRepoCheckoutOptions;
 
+/**
+ * OstreeRepoCheckoutAtOptions:
+ *
+ * An extensible options structure controlling checkout.  Ensure that
+ * you have entirely zeroed the structure, then set just the desired
+ * options.  This is used by ostree_repo_checkout_at() which
+ * supercedes previous separate enumeration usage in
+ * ostree_repo_checkout_tree() and ostree_repo_checkout_tree_at().
+ */
+typedef struct {
+  OstreeRepoCheckoutMode mode;
+  OstreeRepoCheckoutOverwriteMode overwrite_mode;
+
+  gboolean enable_uncompressed_cache;
+  gboolean disable_fsync;
+  gboolean process_whiteouts;
+  gboolean no_copy_fallback;
+
+  const char *subpath;
+
+  OstreeRepoDevInoCache *devino_to_csum_cache;
+
+  int unused_ints[6];
+  gpointer unused_ptrs[7];
+} OstreeRepoCheckoutAtOptions;
+
 _OSTREE_PUBLIC
 GType ostree_repo_devino_cache_get_type (void);
 _OSTREE_PUBLIC
@@ -779,6 +806,15 @@ gboolean ostree_repo_checkout_tree_at (OstreeRepo                         *self,
                                        GCancellable                       *cancellable,
                                        GError                            **error);
 
+_OSTREE_PUBLIC
+gboolean ostree_repo_checkout_at (OstreeRepo                         *self,
+                                  OstreeRepoCheckoutAtOptions        *options,
+                                  int                                 destination_dfd,
+                                  const char                         *destination_path,
+                                  const char                         *commit,
+                                  GCancellable                       *cancellable,
+                                  GError                            **error);
+
 _OSTREE_PUBLIC
 gboolean       ostree_repo_checkout_gc (OstreeRepo        *self,
                                         GCancellable      *cancellable,